
public class Point implements Comparable{

	private double[] cor;
	private int dim;
	
	public Point(double[]cor){
		setCor(cor);
		setDim(cor.length);
	}
	
	public void setDim(int dim) {
		this.dim = dim;
	}
	
	public double[] getCor(){
		return cor;
	}
	
	public void setCor(double[] cor) {
		this.cor = cor;
	}
	
	public double getDistance(Point punt){
		double resultaat = 0;
		double som = 0;
		for (int i = 0; i < dim; i++){
			som += Math.pow(punt.getCor()[i] - this.getCor()[i], 2);
		}
		resultaat = Math.sqrt(som);
		return resultaat;
	}
	
	public int compareTo(Object x){
		final int BEFORE = -1;
		final int EQUAL = 0;
		final int AFTER = 1;
		Point point = (Point) x;
		
		if (point.getCor()[0] > this.getCor()[0])
			return BEFORE;
		else if (point.getCor()[0] < this.getCor()[0])
			return AFTER;
		else
			return EQUAL;
	}
}
